﻿using CSharpGDIDraw.Customshapeform;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace THenu.CSharpGDIDraw.Customshapeform
{
    public class FrmSnow : Form
    {
        private float rateMove = 0.7F;
        private Bitmap m_Snow;
        private Image screenImage;
        private Timer timer = new Timer();
        private static readonly Random rand = new Random();
        private readonly List<SnowFlake> SnowFlakes = new List<SnowFlake>();
        private int Tick = 0;

        public System.ComponentModel.Container components;
        public FrmSnow()
        {
            this.components = new System.ComponentModel.Container();
            InitializeComponent();

            this.timer = new System.Windows.Forms.Timer(this.components);
            this.SuspendLayout();
            // 
            // timer
            // 
            this.timer.Enabled = true;
            this.timer.Interval = 200;
            this.timer.Tick += new System.EventHandler(this.OnTick);
            // 
            // Form1
            // 
            this.ControlBox = false;
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.TopMost = true;
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.ResumeLayout(false);

            SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);

            screenImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);


            // 获取所有静态公共属性 
            foreach (PropertyInfo pi in typeof(System.Drawing.Brushes).GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.GetProperty))
            {
                listBrush.Add((Brush)pi.GetValue(null, null));
            }
        }

        List<string> listContent = new List<string>() {
        "新年快乐","♥","喜洋洋","可爱可欣","Mrs.YXK","😈","♥","👰","美羊羊","ஐ","ஐ","☀","♥","☂","☁","我是灰太狼","♡","♥","☊","♬","❀","懒羊羊","➽","✪小女神✪","ஐ"
        };
        List<Brush> listBrush = new List<Brush>();

        List<Bitmap> listSnow = new List<Bitmap>();
        private void OnTick(object sender, EventArgs args)
        {
            Tick++;
            //new snow flake
            //控制雪量
            if (Tick % 5 == 0)
            {
                SnowFlake s = new SnowFlake();
                s.X = rand.Next(-20, this.Width + 20);
                s.Y = 0f;
                s.XVelocity = (float)(rand.NextDouble() - 0.5f) * 2f;
                s.YVelocity = (float)(rand.NextDouble() * 3) + 1f;
                s.Rotation = rand.Next(0, 359);
                s.RotVelocity = rand.Next(-3, 3) * 2;
                s.PenColor = Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255));
                if (s.RotVelocity == 0)
                {
                    s.RotVelocity = 3;
                }
                s.Scale = (float)(rand.NextDouble() / 2) + 0.75f;
                SnowFlakes.Add(s);
                listSnow.Add(RandomSnow(s.PenColor));
            }
            //To draw snowflake
            Graphics g = Graphics.FromImage(screenImage);
            g.Clear(Color.Transparent);
            g.SmoothingMode = SmoothingMode.HighQuality;

            PointF pointChange = PointF.Empty;

            for (int i = 0; i < SnowFlakes.Count; i++)
            {
                SnowFlake s = SnowFlakes[i];
                if (SnowFlakes[i].Hit)
                {
                    s.X -= s.XVelocity;
                    s.Y -= s.YVelocity;
                }
                else
                {
                    s.X += s.XVelocity;
                    s.Y += s.YVelocity;
                }
                s.Rotation += s.RotVelocity;
                s.XVelocity += ((float)rand.NextDouble() - 0.5f) * rateMove;
                s.XVelocity = Math.Max(s.XVelocity, -2f);
                s.XVelocity = Math.Min(s.XVelocity, +2f);

                s.YVelocity += ((float)rand.NextDouble() - 0.2f) * rateMove;
                //如果雪下到屏幕下面后就让他消失
                if (s.Y > this.Height || s.Y < -50 || s.X < -50 || s.X > this.Width + 50)
                {
                    SnowFlakes.RemoveAt(i);
                    listSnow.RemoveAt(i);
                }
                //没有落到屏幕下面的时候就继续让它往下落
                else
                {
                    // 靠近 DD 则改变形状
                    PointF point = new PointF(s.X, s.Y);
                    if (loveRegion.IsVisible(point))
                    {
                        //SnowFlakes.RemoveAt(i);
                        SnowFlakes[i].Hit = true;
                        listSnow[i] = CreateLove(s.PenColor);
                    }
                    g.ResetTransform();
                    g.TranslateTransform(-30, -30, MatrixOrder.Append); // pan
                    g.ScaleTransform(s.Scale, s.Scale, MatrixOrder.Append); // scale
                    g.RotateTransform(s.Rotation, MatrixOrder.Append); // rotate
                    g.TranslateTransform(s.X, s.Y, MatrixOrder.Append); // pan
                    g.DrawImage(listSnow[i], 0, 0); //draw
                }
            }
            g.Dispose();
            SetBackground(screenImage);
        }



        private class SnowFlake
        {
            public float Rotation;
            public float RotVelocity;
            public float Scale;
            public float X;
            public float XVelocity;
            public float Y;
            public float YVelocity;
            public Color PenColor;
            public bool Hit;
        }

        private void SetBackground(Image img)
        {
            try
            {
                Bitmap bitmap = (Bitmap)img;
                if (bitmap.PixelFormat != PixelFormat.Format32bppArgb)
                {
                    throw new ApplicationException();
                }
                IntPtr hObject = IntPtr.Zero;
                IntPtr zero = IntPtr.Zero;
                IntPtr hDC = Win32.GetDC(IntPtr.Zero);
                IntPtr ptr2 = Win32.CreateCompatibleDC(hDC);
                try
                {
                    hObject = bitmap.GetHbitmap(Color.FromArgb(0));
                    zero = Win32.SelectObject(ptr2, hObject);
                    Win32.Size size2 = new Win32.Size(bitmap.Width, bitmap.Height);
                    Win32.Size psize = size2;
                    Win32.Point point3 = new Win32.Point(0, 0);
                    Win32.Point pprSrc = point3;
                    point3 = new Win32.Point(base.Left, base.Top);
                    Win32.Point pptDst = point3;
                    Win32.BLENDFUNCTION pblend = new Win32.BLENDFUNCTION();
                    pblend.BlendOp = 0;
                    pblend.BlendFlags = 0;
                    pblend.SourceConstantAlpha = 0xff;
                    pblend.AlphaFormat = 1;
                    Win32.UpdateLayeredWindow(this.Handle, hDC, ref pptDst, ref psize, ptr2, ref pprSrc, 0, ref pblend, 2);
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    throw exception;
                }
                finally
                {
                    Win32.ReleaseDC(IntPtr.Zero, hDC);
                    if (hObject != IntPtr.Zero)
                    {
                        Win32.SelectObject(ptr2, zero);
                        Win32.DeleteObject(hObject);
                    }
                    Win32.DeleteDC(ptr2);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }

        protected override System.Windows.Forms.CreateParams CreateParams
        {
            get
            {
                System.Windows.Forms.CreateParams createParams = base.CreateParams;
                createParams.ExStyle |= 0x80000;
                return createParams;
            }
        }

        private Bitmap Snow
        {
            get
            {
                if (m_Snow == null)
                {
                    m_Snow = new Bitmap(32, 32);
                    using (Graphics g = Graphics.FromImage(m_Snow))
                    {
                        g.SmoothingMode = SmoothingMode.AntiAlias;
                        g.Clear(Color.Transparent);
                        g.TranslateTransform(16, 16, MatrixOrder.Append);
                        Color black = Color.FromArgb(1, 1, 1);
                        Color white = Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255));
                        DrawSnow(g, new SolidBrush(black), new Pen(black, 3f));
                        DrawSnow(g, new SolidBrush(white), new Pen(white, 2f));
                        g.Save();
                    }
                }
                return m_Snow;
            }
        }
        private Font myFont = new Font("华文新魏", 20, FontStyle.Bold);
        /// <summary>
        /// 心形图形
        /// </summary>
        /// <returns></returns>
        private Bitmap CreateLove(Color color)
        {
            string charsDraw = listContent[rand.Next(listContent.Count - 1)];
            SizeF mySize = this.CreateGraphics().MeasureString(charsDraw, myFont);
            int sizeX = (int)mySize.Width + 10;
            int sizeY = (int)mySize.Height + 10;
            Font useFont = myFont;
            if (charsDraw.Length == 1)
            {

                mySize = this.CreateGraphics().MeasureString(charsDraw, new Font("华文新魏", 30, FontStyle.Bold));
                sizeX = (int)mySize.Width + 10;
                sizeY = (int)mySize.Height + 10;

            }
            Bitmap m_Snow = new Bitmap(sizeX, sizeY);
            using (Graphics g = Graphics.FromImage(m_Snow))
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.Clear(Color.Transparent);
                g.TranslateTransform(16, 16, MatrixOrder.Append);
                Color white = Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255));
                g.DrawString(charsDraw, useFont, new SolidBrush(white), new PointF(0, 0));
                g.Save();
            }
            return m_Snow;
        }
        /// <summary>
        /// 穿件随机的雪花
        /// </summary>
        /// <returns></returns>
        public Bitmap RandomSnow(Color color)
        {
            Bitmap m_Snow = new Bitmap(32, 32);
            using (Graphics g = Graphics.FromImage(m_Snow))
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.Clear(Color.Transparent);
                g.TranslateTransform(16, 16, MatrixOrder.Append);
                Color black = Color.FromArgb(1, 1, 1);
                //Color white = Color.FromArgb(rand.Next(255), rand.Next(255), rand.Next(255));
                Color white = Color.White;
                DrawSnow(g, new SolidBrush(black), new Pen(black, 3f));
                DrawSnow(g, new SolidBrush(white), new Pen(white, 2f));
                g.Save();
            }
            return m_Snow;
        }

        private static void DrawSnow(Graphics g, Brush b, Pen p)
        {
            const int a = 6;
            const int a2 = a + 2;
            const int r = 2;
            g.DrawLine(p, -a, -a, +a, +a);
            g.DrawLine(p, -a, +a, +a, -a);
            g.DrawLine(p, -a2, 0, +a2, 0);
            g.DrawLine(p, 0, -a2, 0, +a2);
            g.FillEllipse(b, -r, -r, r * 2, r * 2);
        }

        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // FrmSnow
            // 
            this.ClientSize = new System.Drawing.Size(284, 261);
            this.Name = "FrmSnow";
            this.Load += new System.EventHandler(this.FrmSnow_Load);
            this.ResumeLayout(false);

        }
        private Region loveRegion;
        private void FrmSnow_Load(object sender, EventArgs e)
        {
            Mr frmMr = new Mr();
            loveRegion = frmMr.Region.Clone();
            loveRegion.Translate(frmMr.Location.X, frmMr.Location.Y);
            frmMr.MouseWheel += frmMr_MouseWheel;
            frmMr.LocationChanged += frmMr_LocationChanged;
            frmMr.ShowDialog();
            Environment.Exit(0);
        }

        void frmMr_MouseWheel(object sender, MouseEventArgs e)
        {
            if ((e.Delta > 0 && rateMove < 4) || rateMove < 0.5F)
                rateMove += 0.5F;
            else
                rateMove -= 0.5F;
        }

        void frmMr_LocationChanged(object sender, EventArgs e)
        {
            Form frmMr = sender as Form;
            loveRegion = frmMr.Region.Clone();
            loveRegion.Translate(frmMr.Location.X, frmMr.Location.Y);
        }

        #region 字符画
        string contents = @"♧♡♂♀♠♣♥❤☜☞☎☏⊙◎ ☺☻☼▧▨♨◐◑↔↕▪ ▒ ◊◦▣▤▥ ▦▩◘ ◈◇♬♪♩♭♪の★☆→あぃ￡Ю〓§♤♥▶¤๑⊹⊱⋛⋌⋚⊰⊹
≈ ๑۩۩.. ..۩۩๑ ๑۩۞۩๑ ✲ ❈ ✿ ✲ ❈ ➹ ~.~ ◕‿-｡ ☀☂☁【】┱ ┲ ❣ ✚ ✪ ✣ ✤ ✥ ✦❉ ❥ ❦ ❧ ❃ ❂ ❁ ❀ ✄ ☪ ☣ ☢ ☠ ☭

ღღღ ▶ ▷ ◀ ◁ ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ⊙ ☊ ☋ ☌ ☍ⓛⓞⓥⓔ ╬ 『 』∴ ☀ .｡◕‿◕｡ ♫ ♬ ♩ ♭ ♪ ☆ ∷ ﹌ の ★ ◎ ▶☺ ☻ ► ◄ ▧ ▨ ♨ ◐ ◑ ↔ ↕↘ ☼ ▀ ▄ █ ▌░ ▒ ▬ ♦ ◊
☜ ☞ ▐ ░ ▒▬ ♦ ◊ ◦ ☼ ♪ の ☆→ ♧ ぃ ￡ ❤ ｡◕‿◕｡ ✎ ✟ஐ
 
Ƹ̵̡Ӝ̵̨̄Ʒ   ɐəɘε  ♥+~(๑･ิ\\\ω\\\･ิ๑ ) இ 
 ❤♬ ♩♪ ♫ 
≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈
‥‥‥♠‥‥‥♠‥‥‥♠‥‥‥♠‥‥‥♠‥‥‥ 

♡：☏ 。☑  ■ ❀ ♧  ♣. ☼  ◎ ★  ◆ ☀
♥ ♡ ♠ ♤ ♣ ♧ ♪  ▲ ✡ ♨ ☞ ☺ ♦ ◊ ଲ ♘
∞ 卐 ଳ  δ ∮ Θ ▼☜♥☞♧๑۩۞
♡❤♡♡❤♡♡❤♡♡❤♡♡❤♡♡❤♡♡❤♡♡❤♡♡❤♡ 

♥……♥……♥……♥……♥……♥……♥……♥ 

♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡ ♡

✂ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

[ ♨ 下午茶时光 ♨ ]

[ ♤ 治愈的剧♤ ]

~ (ಥ_ಥ)

ƪ(•̃͡ε•̃͡)∫ʃ

(⌇ຶД⌇ຶ)

༼ꉺɷꉺ༽

ಠ_ಠ

(˘❥˘)

ლ(･ิω･ิლ)

✷(ꇐ‿ꇐ)✷

(΄◞ิ౪◟ิ‵ )

(๑꒪◞౪◟꒪๑)

(΄◉◞౪◟◉`)

( ՞ਊ ՞)

(°̥̥̥̥̥̥̥̥-°̥̥̥̥̥̥̥̥ )


(๑•̀.̫•́๑)

(ʘдʘ╬)



๑۩๑


♪ ♬ ๑•ิ.•ั๑ ♠ ♣ ✖ ♂ ♀ ♥ ♡ ☜ ☞ ☎ ☏ ⊙ ◎ ☺ ☻► ◄ ▧ ▨ ♨ ◐ ◑ ↔ ↕ ▪ ▫ ▦ ▩ ◘ ◙ ◈ ♫ ♬ ♪ ♩ ♭ ♪ の ☆→ あ ぃ ￡ ❤ ｡◕‿◕｡ 

•ิ.•ั๑ ๑۩۞۩๑ ♬✿.｡.:* ☂☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☑ ☒☢ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ♠ 　 ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ✙✈ ✉ ✌ ✁ ✎ ✐ ❀ ✰ ❁ ❤ ❥ ❦❧ ➳ ➽ εїз℡❣·۰•●○●
 
＃ ＠ ＆ ＊ ￥☸ ❁ ❀ ✿ ✾ ❃ ✺ ❇ ❈ ❊ ❉ ✱ ✲ ✩ ✫ ✬ ✭ ✮ ✰ ☆ ★ ✪ ¤ ☼ ☀ ☽ ☾ ❤ ♡ ღ☻ ☺ ❂ ◕ ⊕ ☉ Θ o O ♋ ☯ ㊝ ⊙ ◎ ◑ ◐ ۰ • ● ▪ ▫ ｡ ﾟ ๑ ☜ ☞ ☂ ♨ ☎ ☏

▶ ▷ ◀ ◁ ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☑ ☒☢ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ♠ 　 ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ✙ ✈ ✉ ✌ ✁ ✎ ✐ ❀ ✰ ❁ ❤ ❥ ❦❧ ➳ ➽ 〠 〄 ㍿ ♝ ♞

✐✌✍✡✓✔✕✖ ♂ ♀ ♥ ♡ ☜ ☞ ☎ ☏ ⊙ ◎ ☺ ☻ ► ◄ ▧ ▨ ♨ ◐ ◑ ↔ ↕ ♥ ♡ ▪ ▫ ☼ ♦ ▀ ▄ █ ▌ ▐ ░ ▒ ▬ ♦ ◊ ◘ ◙ ◦ ☼ ♠ ♣ ▣ ▤ ▥ ▦ ▩ ◘ ◙ ◈ ♫ ♬ ♪ ♩ ♭ ♪ ✄☪☣☢☠
✗✘✚✪✣✤✥✦✧✩✫✬✭✮✯✰ ✱✲✳❃❂❁❀✿✾✽✼✻✺✹✸✷ ✶✵✴❄❅❆❇❈❉❊❋❖☀☂☁【】┱ ┲ ❣ ✚ ✪ ✣ ✤ ✥ ✦ ❉ ❥ ❦ ❧ ❃ ❂ ❁ ❀ ✄ ☪ ☣ ☢ ☠ ☭ ♈ ➸ ✓ ✔ ✕ ✖ *.:｡✿*ﾟ‘ﾟ･✿.｡.:
♧♡♂♀♠♣♥❤☜☞☎☏⊙◎ ☺☻☼▧▨♨◐◑↔↕▪ ▒ ◊◦▣▤▥ ▦▩◘ ◈◇♬♪♩♭♪の★☆→あぃ￡Ю〓§♤♥▶¤๑⊹⊱⋛⋌⋚⊰⊹
≈ ๑۩۩.. ..۩۩๑ ๑۩۞۩๑ ✲ ❈ ✿ ✲ ❈ ➹ ~.~ ◕‿-｡ ☀☂☁【】┱ ┲ ❣ ✚ ✪ ✣ ✤ ✥ ✦❉ ❥ ❦ ❧ ❃ ❂ ❁ ❀ ✄ ☪ ☣ ☢ ☠ ☭
ღღღ ▶ ▷ ◀ ◁ ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ⊙ ☊ ☋ ☌ ☍ⓛⓞⓥⓔ ╬ 『 』∴ ☀ .｡◕‿◕｡ ♫ ♬ ♩ ♭ ♪ ☆ ∷ ﹌ の ★ ◎ ▶☺ ☻ ► ◄ ▧ ▨ ♨ ◐ ◑ ↔ ↕↘ ☼ ▀ ▄ █ ▌░ ▒ ▬ ♦ ◊
☜ ☞ ▐ ░ ▒▬ ♦ ◊ ◦ ☼ ♪ の ☆→ ♧ ぃ ￡ ❤ ｡◕‿◕｡ ✎ ✟ஐ
♪ ♬ ๑•ิ.•ั๑ ♠ ♣ ✖ ♂ ♀ ♥ ♡ ☜ ☞ ☎ ☏ ⊙ ◎ ☺ ☻► ◄ ▧ ▨ ♨ ◐ ◑ ↔ ↕ ▪ ▫ ▦ ▩ ◘ ◙ ◈ ♫ ♬ ♪ ♩ ♭ ♪ の ☆→ あ ぃ ￡ ❤ ｡◕‿◕｡ 
•ิ.•ั๑ ๑۩۞۩๑ ♬✿.｡.:* ☂☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☑ ☒☢ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ♠ 　 ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ✙✈ ✉ ✌ ✁ ✎ ✐ ❀ ✰ ❁ ❤ ❥ ❦❧ ➳ ➽ εїз℡❣·۰•●○●
＃ ＠ ＆ ＊ ￥☸ ❁ ❀ ✿ ✾ ❃ ✺ ❇ ❈ ❊ ❉ ✱ ✲ ✩ ✫ ✬ ✭ ✮ ✰ ☆ ★ ✪ ¤ ☼ ☀ ☽ ☾ ❤ ♡ ღ☻ ☺ ❂ ◕ ⊕ ☉ Θ o O ♋ ☯ ㊝ ⊙ ◎ ◑ ◐ ۰ • ● ▪ ▫ ｡ ﾟ ๑ ☜ ☞ ☂ ♨ ☎ ☏
▶ ▷ ◀ ◁ ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☑ ☒☢ ☸ ☹ ☺ ☻ ☼ ☽ ☾ ♠ 　 ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ✙ ✈ ✉ ✌ ✁ ✎ ✐ ❀ ✰ ❁ ❤ ❥ ❦❧ ➳ ➽ 〠 〄 ㍿ ♝ ♞
✐✌✍✡✓✔✕✖ ♂ ♀ ♥ ♡ ☜ ☞ ☎ ☏ ⊙ ◎ ☺ ☻ ► ◄ ▧ ▨ ♨ ◐ ◑ ↔ ↕ ♥ ♡ ▪ ▫ ☼ ♦ ▀ ▄ █ ▌ ▐ ░ ▒ ▬ ♦ ◊ ◘ ◙ ◦ ☼ ♠ ♣ ▣ ▤ ▥ ▦ ▩ ◘ ◙ ◈ ♫ ♬ ♪ ♩ ♭ ♪ ✄☪☣☢☠
✗✘✚✪✣✤✥✦✧✩✫✬✭✮✯✰ ✱✲✳❃❂❁❀✿✾✽✼✻✺✹✸✷ ✶✵✴❄❅❆❇❈❉❊❋❖☀☂☁【】┱ ┲ ❣ ✚ ✪ ✣ ✤ ✥ ✦ ❉ ❥ ❦ ❧ ❃ ❂ ❁ ❀ ✄ ☪ ☣ ☢ ☠ ☭ ♈ ➸ ✓ ✔ ✕ ✖ *.:｡✿*ﾟ‘ﾟ･✿.｡.: 
";
        #endregion
    }
    internal class Win32
    {
        public const byte AC_SRC_ALPHA = 1;
        public const byte AC_SRC_OVER = 0;
        public const int ULW_ALPHA = 2;

        [DllImport("gdi32.dll")]
        public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
        [DllImport("gdi32.dll")]
        public static extern Bool DeleteDC(IntPtr hdc);
        [DllImport("gdi32.dll")]
        public static extern Bool DeleteObject(IntPtr hObject);
        [DllImport("user32.dll")]
        public static extern IntPtr GetDC(IntPtr handle);
        [DllImport("user32.dll", ExactSpelling = true)]
        public static extern int ReleaseDC(IntPtr handle, IntPtr hDC);
        [DllImport("gdi32.dll")]
        public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject);
        [DllImport("user32.dll")]
        public static extern Bool UpdateLayeredWindow(IntPtr handle, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pprSrc, int crKey, ref BLENDFUNCTION pblend, int dwFlags);

        [StructLayout(LayoutKind.Sequential)]
        public struct BLENDFUNCTION
        {
            public byte BlendOp;
            public byte BlendFlags;
            public byte SourceConstantAlpha;
            public byte AlphaFormat;
        }

        public enum Bool
        {
            False,
            True
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct Point
        {
            public int x;
            public int y;
            public Point(int x, int y)
            {
                this.x = x;
                this.y = y;
            }
        }

        [StructLayout(LayoutKind.Sequential)]
        public struct Size
        {
            public int cx;
            public int cy;
            public Size(int cx, int cy)
            {
                this.cx = cx;
                this.cy = cy;
            }
        }

    }
}
